﻿using Microsoft.Extensions.DependencyInjection;
using Modules.BankSpecialAccount.Entitys;
using Modules.BankSpecialAccount.Repositories;
using PmSoft;

namespace Modules.BankSpecialAccount
{
    [UseDI(ServiceLifetime.Scoped)]
    public class BankSpecialAccountPaymentDetailsService
    {
        private readonly BankSpecialAccountPaymentDetailsRepository ProjectSpecialAccountPaymentDetailsRepository;

        public BankSpecialAccountPaymentDetailsService(BankSpecialAccountPaymentDetailsRepository ProjectSpecialAccountPaymentDetailsRepository)
        {
            this.ProjectSpecialAccountPaymentDetailsRepository = ProjectSpecialAccountPaymentDetailsRepository;
        }

        public void CreateProjectSpecialAccountPaymentDetails(BankSpecialAccountPaymentDetails entity)
        {
            ProjectSpecialAccountPaymentDetailsRepository.Insert(entity);
        }

        public void DeletProjectSpecialAccountPaymentDetailss(IEnumerable<int> ids)
        {
            foreach (int id in ids)
                DeleteProjectSpecialAccountPaymentDetails(id);
        }

        public void DeleteProjectSpecialAccountPaymentDetails(int id)
        {
            ProjectSpecialAccountPaymentDetailsRepository.DeleteByEntityId(id);
        }

        public BankSpecialAccountPaymentDetails? GetProjectSpecialAccountPaymentDetails(int id)
        {
            return ProjectSpecialAccountPaymentDetailsRepository.Get(id);
        }

        public void UpdateProjectSpecialAccountPaymentDetails(BankSpecialAccountPaymentDetails entity)
        {
            ProjectSpecialAccountPaymentDetailsRepository.Update(entity);
        }

        public IPagedList<BankSpecialAccountPaymentDetails> GetProjectSpecialAccountPaymentDetailsList(BankSpecialAccountPaymentDetailsQuery query, int pageIndex, int pageSize)
        {
            return ProjectSpecialAccountPaymentDetailsRepository.GetProjectSpecialAccountPaymentDetailsList(query, pageIndex, pageSize);
        }

        /// <summary>
        /// 是否存在对应的代发明细
        /// </summary>
        /// <param name="htSerial"></param>
        /// <param name="batchNo"></param>
        /// <param name="tradeSerial"></param>
        /// <returns></returns>
        public bool ExistPaymentDetail(string htSerial, string batchNo, string tradeSerial)
        {
            return ProjectSpecialAccountPaymentDetailsRepository.ExistPaymentDetail(htSerial, batchNo, tradeSerial);
        }
    }
}